﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmlEngine.Sprites
{
    public static class VisibilityExtensions
    {
        #region Old
        /*
        public bool Exists
        {
            get { return Visibility != Visibility.DoesNotExist; }
            set 
            {
                if (value)
                {
                    if (Visibility != Visibility.DoesNotExist) return;
                    Visibility = Visibility.Exists;
                }
                else
                {
                    Visibility = Visibility.DoesNotExist;
                }
            }
        }
        public bool IsActive
        {
            get
            {
                return Visibility == Visibility.Active ||
                       Visibility == Visibility.Visible;
            }
            set
            {
                if (value)
                {
                    if (Visibility == Visibility.Visible) return;
                    Visibility = Visibility.Active;
                }
                else
                {
                    Visibility = Visibility.Exists;
                }
            }
        }
        public bool IsVisible
        {
            get { return Visibility == Visibility.Visible; }
            set
            {
                if (value)
                {
                    Visibility = Visibility.Visible;
                }
                else
                {
                    if (Visibility != Visibility.Visible) return;
                    Visibility = Visibility.Active;
                }
            }
        }
        */
        #endregion

        /// <summary>
        /// Determines if an object exists.
        /// </summary>
        /// <returns>If the object exists.</returns>
        public static bool Exists(this Visibility visibility)
        {
            return visibility != Visibility.DoesNotExist;
        }

        /// <summary>
        /// Returns if this object is active.
        /// </summary>
        /// <returns>If this object is active.</returns>
        public static bool IsActive(this Visibility visibility)
        {
            return visibility == Visibility.Active ||
                   visibility == Visibility.Exists;
        }

        /// <summary>
        /// Determines if this object is visible.
        /// </summary>
        /// <returns>The visibility of this object.</returns>
        public static bool IsVisible(this Visibility visibility)
        {
            return visibility == Visibility.Visible;
        }
    }

    /// <summary>
    /// An enumeration specifying the visibility of an item.
    /// </summary>
    public enum Visibility
    {
        /// <summary>
        /// The item does not exist.
        /// </summary>
        DoesNotExist = 0,

        /// <summary>
        /// The item exists. In the context of a scene, the scene contains a reference to the item.
        /// </summary>
        Exists = 1,

        /// <summary>
        /// The item exists, and is active. In the context of a scene, the scene contains 
        /// a reference to an item, and will update the item on its Update cycle.
        /// </summary>
        Active = 2,

        /// <summary>
        /// The item exists, and is active. In the context of a scene, 
        /// the scene contains a reference to an item, and will update the 
        /// item on its Update cycle, and draw the item in its Draw cycle.
        /// </summary>
        Visible = 3
    }
}
